package com.su.lesson04;

import javax.swing.*;
import java.awt.*;
import java.awt.event.*;

public class DialogDemo extends JFrame {

    //JFrame放东西，容器

    public DialogDemo() {
        Container container = getContentPane();
        this.setVisible(true);
        this.setTitle("这是一个容器");
        this.setBounds(100, 100, 450, 300);
        //绝对布局
        this.setLayout(null);
        this.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
        //按钮
        JLabel button = new JLabel("点击弹出对话框");
        button.setBounds(10, 10, 100, 30);
        //点击这个按钮时，弹出一个弹窗

        button.addMouseListener(new MouseAdapter() {
            @Override
            public void mouseClicked(MouseEvent e) {
                //弹窗
                new MyDialogDemo();
            }
        });


         container.add(button);
    }

    public static void main(String[] args) {
        new DialogDemo();
    }

}
//弹窗的窗口
class MyDialogDemo extends JDialog {
    public MyDialogDemo() {
        this.setVisible(true);
        this.setBounds(100, 100, 450, 300);
        this.setLayout(null);
    }
}